package jmine.tec.services.api.export;

import java.util.Collections;
import java.util.List;

import jmine.tec.services.io.ServiceBean;

/**
 * @author lundberg
 * @param <E>
 */
public abstract class AbstractServiceFillerEntityExporter<E> extends AbstractEntityExporter<E> {

    private final ServiceFiller<E> serviceFiller;

    /**
     * Construtor padrão
     * 
     * @param serviceFiller serviceFiller
     * @param action action
     */
    public AbstractServiceFillerEntityExporter(ServiceFiller<E> serviceFiller, ExportAction action) {
        super(action);
        this.serviceFiller = serviceFiller;
    }

    /**
     * {@inheritDoc}
     */
    public List<ServiceBean> export(ReferenceMap referenceMap, E entity) {
        ServiceBean bean = new ServiceBean();
        this.getServiceFiller().fillServiceBean(bean, referenceMap, entity);
        return Collections.singletonList(bean);
    }

    /**
     * @return the serviceFiller
     */
    public ServiceFiller<E> getServiceFiller() {
        return this.serviceFiller;
    }
}
